import request from '@/utils/request'

export default {
  //获取全部权限列表
  getAllPermissions() {
    return request({
      url: "/api/v1/admin/permission/getPermissionTree",
      method: 'get'
    })
  },
  //获取角色权限列表
  getRolePermission(roleId){
    return request({
      url: "/api/v1/admin/permission/getPermissionTreeByRoleId/"+roleId,
      method: 'get'
    })
  },
  //为权限添加子权限
  addPermission(permission,permissionId){
    return request({
      url: "/api/v1/admin/permission/addPermission/"+permissionId,
      method: 'post',
      data:permission
    })
  },
  //根据权限Id获取权限list
  getPermissionListById(permissionId){
    return request({
      url: "/api/v1/admin/permission/getPermissionListById/"+permissionId,
      method: 'get'
    })
  },
  //根据权限Id获取权限信息
  getPermissionById(permissionId){
    return request({
      url: "/api/v1/admin/permission/getPermissionById/"+permissionId,
      method: 'get'
    })
  },
  //修改权限信息
  updatePermission(permission){
    return request({
      url: "/api/v1/admin/permission/updatePermission",
      method: 'put',
      data:permission
    })
  },
  //根据权限Id删除权限
  deletePermissionById(permissionId){
    return request({
      url: "/api/v1/admin/permission/deletePermissionById/"+permissionId,
      method: 'delete'
    })
  },
  //根据角色Id查询该角色未拥有的权限树
  getRoleNotOwnedPermissionByRoleId(roleId){
    return request({
      url: "/api/v1/admin/permission/getRoleNotOwnedPermissionByRoleId/"+roleId,
      method: 'get'
    })
  },
  //授权
  distributionPermission(roleId,permissionId,notOwnerList){
    return request({
      url: "/api/v1/admin/permission/distributionPermission/"+roleId+"/"+permissionId,
      method: 'post',
      data:notOwnerList
    })
  },
  //取消授权
  notDistributionPermission(roleId,permissionId,ownerList){
    return request({
      url: "/api/v1/admin/permission/notDistributionPermission/"+roleId+"/"+permissionId,
      method: 'post',
      data:ownerList
    })
  }
}
